home *** CD-ROM | disk | FTP | other *** search
/ The X-Philes (2nd Revision) / The X-Philes Number 1 (1995).iso / xphiles / hp95 / freyja.exe / lha / TABLE.C < prev    next >
C/C++ Source or Header  |  1992-04-13  |  28KB  |  897 lines

  1. /* TABLE.C -- Command Table Routines
  2.  
  3.     Written March 1991 by Craig A. Finseth
  4.     Copyright 1991 by Craig A. Finseth
  5. */
  6.  
  7. #include "freyja.h"
  8.  
  9. struct cmd {
  10.     void (*proc)();        /* procedure to invoke */
  11.     char *help;        /* help string */
  12.     };
  13.  
  14. struct func_cmd {
  15.     void (*proc)();        /* procedure to invoke */
  16.     char *help;        /* help string */
  17.     char *keyname;        /* key name */
  18.     };
  19.  
  20. /* command table conventions are:
  21.  
  22.     0 - base
  23.     1 - control-x
  24.     2 - meta
  25.     3 - function keys
  26. */
  27.  
  28. /* In help strings:
  29.  
  30.     @    no command
  31.     ^    self-insert
  32. */
  33.  
  34.     /* base commands */
  35. static struct cmd base[] = {
  36. { RMarkSet,    "set the mark to the point" },            /* ^@ */
  37. { CLineA,    "move to the beginning of the line" },        /* ^A */
  38. { CCharB,    "move backward character" },            /* ^B */
  39. { WCaseRotate,    "rotate case of word lower->Capital->UPPER" },    /* ^C */
  40. { CCharFD,    "delete the following character" },        /* ^D */
  41. { CLineE,    "move to the end of the line" },        /* ^E */
  42. { CCharF,    "move forward character" },            /* ^F */
  43. { MAbort,    "abort, cancel" },                /* ^G */
  44. { CCharBD,    "delete the preceding character" },        /* ^H */
  45. { MInsChar,    "insert Tab" },                    /* ^I */
  46. { WIndNext,    "insert Newline and indent" },            /* ^J */
  47. { CLineFD,    "kill / delete the rest of the line" },        /* ^K */
  48. { DScreenRange,    "recenter the screen" },            /* ^L */
  49. { WInsNL,    "insert Newline" },                /* ^M */
  50. { CLineF,    "move to the next line" },            /* ^N */
  51. { WInsNLA,    "open line" },                    /* ^O */
  52.  
  53. { CLineB,    "move to the previous line" },            /* ^P */
  54. { MQuote,    "quote the next command" },            /* ^Q */
  55. { MSearchB,    "reverse / backward search" },            /* ^R */
  56. { MSearchF,    "forward search" },                /* ^S */
  57. { CCharTran,    "interchange preceding characters" },        /* ^T */
  58. { MUArg,    "universal argument" },                /* ^U */
  59. { CScrnF,    "move to the next screen" },            /* ^V */
  60. { RRegDelete,    "delete region to kill buffer: cut" },        /* ^W */
  61. { MCtrlX,    "^X command prefix" },                /* ^X */
  62. { RYank,    "yank kill buffer: paste" },            /* ^Y */
  63. { CScrnB,    "move to the previous screen" },        /* ^Z */
  64. { MMeta,    "^[ meta command prefix" },            /* ^[ */
  65. { WIndDel,    "delete indentation on line" },            /* ^\ */
  66. { KFromMac,    "invoke keyboard macro" },            /* ^] */
  67. { MNotImpl,    "@" },                        /* ^^ */
  68. { MNotImpl,    "@" },                        /* ^_ */
  69.  
  70. { MInsChar,    "^" },                        /*   */
  71. { MInsChar,    "^" },                        /* ! */
  72. { MInsChar,    "^" },                        /* " */
  73. { MInsChar,    "^" },                        /* # */
  74. { MInsChar,    "^" },                        /* $ */
  75. { MInsChar,    "^" },                        /* % */
  76. { MInsChar,    "^" },                        /* & */
  77. { MInsChar,    "^" },                        /* ' */
  78. { MInsChar,    "^" },                        /* ( */
  79. { MInsChar,    "^" },                        /* ) */
  80. { MInsChar,    "^" },                        /* * */
  81. { MInsChar,    "^" },                        /* + */
  82. { MInsChar,    "^" },                        /* , */
  83. { MInsChar,    "^" },                        /* - */
  84. { MInsChar,    "^" },                        /* . */
  85. { MInsChar,    "^" },                        /* / */
  86.  
  87. { MInsChar,    "^" },                        /* 0 */
  88. { MInsChar,    "^" },                        /* 1 */
  89. { MInsChar,    "^" },                        /* 2 */
  90. { MInsChar,    "^" },                        /* 3 */
  91. { MInsChar,    "^" },                        /* 4 */
  92. { MInsChar,    "^" },                        /* 5 */
  93. { MInsChar,    "^" },                        /* 6 */
  94. { MInsChar,    "^" },                        /* 7 */
  95. { MInsChar,    "^" },                        /* 8 */
  96. { MInsChar,    "^" },                        /* 9 */
  97. { MInsChar,    "^" },                        /* : */
  98. { MInsChar,    "^" },                        /* ; */
  99. { MInsChar,    "^" },                        /* < */
  100. { MInsChar,    "^" },                        /* = */
  101. { MInsChar,    "^" },                        /* > */
  102. { MInsChar,    "^" },                        /* ? */
  103.  
  104. { MInsChar,    "^" },                        /* @ */
  105. { MInsChar,    "^" },                        /* A */
  106. { MInsChar,    "^" },                        /* B */
  107. { MInsChar,    "^" },                        /* C */
  108. { MInsChar,    "^" },                        /* D */
  109. { MInsChar,    "^" },                        /* E */
  110. { MInsChar,    "^" },                        /* F */
  111. { MInsChar,    "^" },                        /* G */
  112. { MInsChar,    "^" },                        /* H */
  113. { MInsChar,    "^" },                        /* I */
  114. { MInsChar,    "^" },                        /* J */
  115. { MInsChar,    "^" },                        /* K */
  116. { MInsChar,    "^" },                        /* L */
  117. { MInsChar,    "^" },                        /* M */
  118. { MInsChar,    "^" },                        /* N */
  119. { MInsChar,    "^" },                        /* O */
  120.  
  121. { MInsChar,    "^" },                        /* P */
  122. { MInsChar,    "^" },                        /* Q */
  123. { MInsChar,    "^" },                        /* R */
  124. { MInsChar,    "^" },                        /* S */
  125. { MInsChar,    "^" },                        /* T */
  126. { MInsChar,    "^" },                        /* U */
  127. { MInsChar,    "^" },                        /* V */
  128. { MInsChar,    "^" },                        /* W */
  129. { MInsChar,    "^" },                        /* X */
  130. { MInsChar,    "^" },                        /* Y */
  131. { MInsChar,    "^" },                        /* Z */
  132. { MInsChar,    "^" },                        /* [ */
  133. { MInsChar,    "^" },                        /* \ */
  134. { MInsChar,    "^" },                        /* ] */
  135. { MInsChar,    "^" },                        /* ^ */
  136. { MInsChar,    "^" },                        /* _ */
  137.  
  138. { MInsChar,    "^" },                        /* ` */
  139. { MInsChar,    "^" },                        /* a */
  140. { MInsChar,    "^" },                        /* b */
  141. { MInsChar,    "^" },                        /* c */
  142. { MInsChar,    "^" },                        /* d */
  143. { MInsChar,    "^" },                        /* e */
  144. { MInsChar,    "^" },                        /* f */
  145. { MInsChar,    "^" },                        /* g */
  146. { MInsChar,    "^" },                        /* h */
  147. { MInsChar,    "^" },                        /* i */
  148. { MInsChar,    "^" },                        /* j */
  149. { MInsChar,    "^" },                        /* k */
  150. { MInsChar,    "^" },                        /* l */
  151. { MInsChar,    "^" },                        /* m */
  152. { MInsChar,    "^" },                        /* n */
  153. { MInsChar,    "^" },                        /* o */
  154.  
  155. { MInsChar,    "^" },                        /* p */
  156. { MInsChar,    "^" },                        /* q */
  157. { MInsChar,    "^" },                        /* r */
  158. { MInsChar,    "^" },                        /* s */
  159. { MInsChar,    "^" },                        /* t */
  160. { MInsChar,    "^" },                        /* u */
  161. { MInsChar,    "^" },                        /* v */
  162. { MInsChar,    "^" },                        /* w */
  163. { MInsChar,    "^" },                        /* x */
  164. { MInsChar,    "^" },                        /* y */
  165. { MInsChar,    "^" },                        /* z */
  166. { MInsChar,    "^" },                        /* { */
  167. { MInsChar,    "^" },                        /* | */
  168. { MInsChar,    "^" },                        /* } */
  169. { MInsChar,    "^" },                        /* ~ */
  170. #if defined(UNIX)
  171. { CCharBD,    "delete the preceding character" } };        /* ^? */
  172. #endif
  173. #if defined(MSDOS)
  174. { WWordBD,    "delete the preceding word" } };        /* ^? */
  175. #endif
  176.  
  177.     /* control-x commands */
  178. static struct cmd ctlx[] = {
  179. { MNotImpl,    "@" },                        /* ^@ */
  180. { MNotImpl,    "@" },                        /* ^A */
  181. { FBufList,    "list the buffers" },                /* ^B */
  182. { MExit,    "exit the editor" },                /* ^C */
  183. { FDIRED,    "DIRED: directory display" },            /* ^D */
  184. #if !defined(NOEXEC)
  185. { FCommand,    "execute system command" },            /* ^E */
  186. #else
  187. { MNotImpl,    "@" },                        /* ^E */
  188. #endif
  189. { FFileFind,    "find a file, creating new buffer" },        /* ^F */
  190. { MAbort,    "abort, cancel" },                /* ^G */
  191. { WSentBD,    "delete the preceding sentence" },        /* ^H */
  192. { MNotImpl,    "@" },                        /* ^I */
  193. { MNotImpl,    "@" },                        /* ^J */
  194. { MNotImpl,    "@" },                        /* ^K */
  195. { RLower,    "lowercase the region" },            /* ^L */
  196. { MNotImpl,    "@" },                        /* ^M */
  197. { MNotImpl,    "@" },                        /* ^N */
  198. { MNotImpl,    "@" },                        /* ^O */
  199.  
  200. { MNotImpl,    "@" },                        /* ^P */
  201. { MNotImpl,    "@" },                        /* ^Q */
  202. { FFileRead,    "read a file into the buffer" },        /* ^R */
  203. { FFileSave,    "save the buffer using current name" },        /* ^S */
  204. { MNotImpl,    "@" },                        /* ^T */
  205. { RUpper,    "UPPERCASE the region" },            /* ^U */
  206. { CScrnFOW,    "move to next screen in other window" },    /* ^V */
  207. { FFileWrite,    "ask for filename and write the buffer" },    /* ^W */
  208. { RMarkSwap,    "interchange the point and mark" },        /* ^X */
  209. { MNotImpl,    "@" },                        /* ^Y */
  210. { CScrnBOW,    "move to previous screen in other window" },    /* ^Z */
  211. { MNotImpl,    "@" },                        /* ^[ */
  212. { RDelWhite,    "delete trailing whitespace on lines in the region" },/* ^\ */
  213. { MNotImpl,    "@" },                        /* ^] */
  214. { MNotImpl,    "@" },                        /* ^^ */
  215. { MNotImpl,    "@" },                        /* ^_ */
  216.  
  217. { MNotImpl,    "@" },                        /*   */
  218. { MNotImpl,    "@" },                        /* ! */
  219. { MNotImpl,    "@" },                        /* " */
  220. { WPrintMar,    "display the margin settings" },        /* # */
  221. { MNotImpl,    "@" },                        /* $ */
  222. { MNotImpl,    "@" },                        /* % */
  223. { MNotImpl,    "@" },                        /* & */
  224. { MNotImpl,    "@" },                        /* ' */
  225. { KBegMac,    "start collecting keyboard macro" },        /* ( */
  226. { KEndMac,    "end collecting keyboard macro" },        /* ) */
  227. { MNotImpl,    "@" },                        /* * */
  228. { MNotImpl,    "@" },                        /* + */
  229. { WSetTabs,    "set this buffer's tab spacing to the argument" }, /* , */
  230. { MNotImpl,    "@" },                        /* - */
  231. { WSetLeft,    "set this buffer's left margin to the argument" }, /* . */
  232. { WSetFill,    "set this buffer's fill mode" },        /* / */
  233.  
  234. { MNotImpl,    "@" },                        /* 0 */
  235. { DWindOne,    "set one window" },                /* 1 */
  236. { DWindTwo,    "set two windows" },                /* 2 */
  237. { DWindTwoO,    "set two windows, leave the point in other window" },/* 3 */
  238. { MNotImpl,    "@" },                        /* 4 */
  239. { MNotImpl,    "@" },                        /* 5 */
  240. { MNotImpl,    "@" },                        /* 6 */
  241. { MNotImpl,    "@" },                        /* 7 */
  242. { MIns8,    "insert the argument as a character" },        /* 8 */
  243. { MNotImpl,    "@" },                        /* 9 */
  244. { MNotImpl,    "@" },                        /* : */
  245. { MNotImpl,    "@" },                        /* ; */
  246. { DLeft,    "scroll the window left" },            /* < */
  247. { WPrintPos,    "display position" },                /* = */
  248. { DRight,    "scroll the window right" },            /* > */
  249. { MNotImpl,    "@" },                        /* ? */
  250.  
  251. { MNotImpl,    "@" },                        /* @ */
  252. { MNotImpl,    "@" },                        /* A */
  253. { FBufNext,    "move to the next buffer in the ring" },    /* B */
  254. { MExit,    "exit / quit the editor" },            /* C */
  255. { MNotImpl,    "@" },                        /* D */
  256. { KFromMac,    "invoke keyboard macro" },            /* E */
  257. { WSetRight,    "set this buffer's right margin to the argument" }, /* F */
  258. { MNotImpl,    "@" },                        /* G */
  259. { HHelp,    "help" },                    /* H */
  260. { MNotImpl,    "@" },                        /* I */
  261. { MNotImpl,    "@" },                        /* J */
  262. { FBufDel,    "delete a buffer" },                /* K */
  263. { MNotImpl,    "@" },                        /* L */
  264. { MNotImpl,    "@" },                        /* M */
  265. { MNotImpl,    "@" },                        /* N */
  266. { DWindSwap,    "move / switch to the other window" },        /* O */
  267.  
  268. { MNotImpl,    "@" },                        /* P */
  269. { MQuote,    "quote the next command" },            /* Q */
  270. { MNotImpl,    "@" },                        /* R */
  271. { MSearchF,    "forward search" },                /* S */
  272. { RTabify,    "tabify the region" },                /* T */
  273. { RUntabify,    "untabify the region" },            /* U */
  274. { FBufPrev,    "move to the previous buffer in the ring" },    /* P */
  275. { MNotImpl,    "@" },                        /* W */
  276. { MNotImpl,    "@" },                        /* X */
  277. { MNotImpl,    "@" },                        /* Y */
  278. { MNotImpl,    "@" },                        /* Z */
  279. { ROutdent,    "outdent the region" },                /* [ */
  280. { MNotImpl,    "@" },                        /* \ */
  281. { RIndent,    "indent the region" },                /* ] */
  282. { DWindGrow,    "grow the current window" },            /* ^ */
  283. { MNotImpl,    "@" },                        /* _ */
  284.  
  285. { DTogVisGray,    "toggle whether grayspace is visible" },    /* ` */
  286. { MNotImpl,    "@" },                        /* a */
  287. { FBufNext,    "move to the next buffer in the ring" },    /* b */
  288. { MExit,    "exit / quit the editor" },            /* c */
  289. { MNotImpl,    "@" },                        /* d */
  290. { KFromMac,    "invoke keyboard macro" },            /* e */
  291. { WSetRight,    "set this buffer's right margin to the argument" }, /* f */
  292. { MNotImpl,    "@" },                        /* g */
  293. { HHelp,    "help" },                    /* h */
  294. { MNotImpl,    "@" },                        /* i */
  295. { MNotImpl,    "@" },                        /* j */
  296. { FBufDel,    "delete a buffer" },                /* k */
  297. { MNotImpl,    "@" },                        /* l */
  298. { MNotImpl,    "@" },                        /* m */
  299. { MNotImpl,    "@" },                        /* n */
  300. { DWindSwap,    "move / switch to the other window" },        /* o */
  301.  
  302. { MNotImpl,    "@" },                        /* p */
  303. { MQuote,    "quote the next command" },            /* q */
  304. { MNotImpl,    "@" },                        /* r */
  305. { MSearchF,    "forward search" },                /* s */
  306. { RTabify,    "tabify the region" },                /* t */
  307. { RUntabify,    "untabify the region" },            /* u */
  308. { FBufPrev,    "move to the previous buffer in the ring" },    /* p */
  309. { MNotImpl,    "@" },                        /* w */
  310. { MNotImpl,    "@" },                        /* x */
  311. { MNotImpl,    "@" },                        /* y */
  312. { MNotImpl,    "@" },                        /* z */
  313. { RHardToSoft,    "convert hard newlines to soft" },        /* { */
  314. { MNotImpl,    "@" },                        /* | */
  315. { RSoftToHard,    "convert soft newlines to hard" },        /* } */
  316. { MNotImpl,    "@" },                        /* ~ */
  317. { WSentBD,    "delete the preceding sentence" } };        /* ^? */
  318.  
  319.     /* meta commands */
  320. static struct cmd meta[] = {
  321. { MNotImpl,    "@" },                        /* ^@ */
  322. #if !defined(NOCALC)
  323. { WNumMark,    "mark the current number" },            /* ^A */
  324. { WNumB,    "move backward number" },            /* ^B */
  325. #else
  326. { MNotImpl,    "@" },                        /* ^A */
  327. { MNotImpl,    "@" },                        /* ^B */
  328. #endif
  329. { DCal,        "display a calendar for the current month" },    /* ^C */
  330. { MNotImpl,    "@" },                        /* ^D */
  331. #if !defined(NOCALC)
  332. { UEnter,    "enter the current number into the calculator" },/* ^E */
  333. { WNumF,    "move forward number" },            /* ^F */
  334. #else
  335. { MNotImpl,    "@" },                        /* ^E */
  336. { MNotImpl,    "@" },                        /* ^F */
  337. #endif
  338. { MAbort,    "abort, cancel" },                /* ^G */
  339. { WWordBD,    "delete the preceding word" },            /* ^H */
  340. { MNotImpl,    "@" },                        /* ^I */
  341. { MNotImpl,    "@" },                        /* ^J */
  342. { CLineAED,    "delete the current line" },            /* ^K */
  343. { DNewDisplay,    "refresh and recenter the screen" },        /* ^L */
  344. #if !defined(NOCALC)
  345. { UPrintX,    "insert the X register; if arg, do ^[ ^A ^W first" },/* ^M */
  346. #else
  347. { MNotImpl,    "@" },                        /* ^M */
  348. #endif
  349. { DNext,    "advance the calendar a month" },        /* ^N */
  350. { MNotImpl,    "@" },                        /* ^O */
  351.  
  352. { DPrev,    "rewind the calendar a month" },        /* ^P */
  353. { MNotImpl,    "@" },                        /* ^Q */
  354. { MReplaceQ,    "query global search and replace string" },    /* ^R */
  355. { MNotImpl,    "@" },                        /* ^S */
  356. { MNotImpl,    "@" },                        /* ^T */
  357. #if !defined(NOCALC)
  358. { UCalc,    "RPN calculator" },                /* ^U */
  359. #else
  360. { MNotImpl,    "@" },                        /* ^U */
  361. #endif
  362. { MNotImpl,    "@" },                        /* ^V */
  363. { MMakeDelete,    "append the next kill to the kill buffer" },    /* ^W */
  364. { MNotImpl,    "@" },                        /* ^X */
  365. { MNotImpl,    "@" },                        /* ^Y */
  366. { MNotImpl,    "@" },                        /* ^Z */
  367. { MNotImpl,    "@" },                        /* ^[ */
  368. { MNotImpl,    "@" },                        /* ^\ */
  369. #if !defined(NOCALC)
  370. { ULoadMac,    "load or save the keyboard macro" },        /* ^] */
  371. #else
  372. { MNotImpl,    "@" },                        /* ^] */
  373. #endif
  374. { MNotImpl,    "@" },                        /* ^^ */
  375. { MNotImpl,    "@" },                        /* ^_ */
  376.  
  377. { RMarkSet,    "set the mark to the point" },            /*   */
  378. { MNotImpl,    "@" },                        /* ! */
  379. { MNotImpl,    "@" },                        /* " */
  380. { MNotImpl,    "@" },                        /* # */
  381. { MNotImpl,    "@" },                        /* $ */
  382. { MNotImpl,    "@" },                        /* % */
  383. { MNotImpl,    "@" },                        /* & */
  384. { MNotImpl,    "@" },                        /* ' */
  385. { MNotImpl,    "@" },                        /* ( */
  386. { MNotImpl,    "@" },                        /* ) */
  387. { MNotImpl,    "@" },                        /* * */
  388. { MNotImpl,    "@" },                        /* + */
  389. { MNotImpl,    "@" },                        /* , */
  390. { MNotImpl,    "@" },                        /* - */
  391. { MNotImpl,    "@" },                        /* . */
  392. { MNotImpl,    "@" },                        /* / */
  393.  
  394. { MNotImpl,    "@" },                        /* 0 */
  395. { MNotImpl,    "@" },                        /* 1 */
  396. { MNotImpl,    "@" },                        /* 2 */
  397. { MNotImpl,    "@" },                        /* 3 */
  398. { MNotImpl,    "@" },                        /* 4 */
  399. { MNotImpl,    "@" },                        /* 5 */
  400. { MNotImpl,    "@" },                        /* 6 */
  401. { MNotImpl,    "@" },                        /* 7 */
  402. { MNotImpl,    "@" },                        /* 8 */
  403. { MNotImpl,    "@" },                        /* 9 */
  404. { MNotImpl,    "@" },                        /* : */
  405. { MNotImpl,    "@" },                        /* ; */
  406. { FBufBeg,    "move to the beginning of the buffer" },    /* < */
  407. { WPrintLine,    "display line counts" },            /* = */
  408. { FBufEnd,    "move to the end of the buffer" },        /* > */
  409. { MNotImpl,    "@" },                        /* ? */
  410.  
  411. { MNotImpl,    "@" },                        /* @ */
  412. { WSentB,    "move backward sentence" },            /* A */
  413. { WWordB,    "move backward word" },                /* B */
  414. { WWordCap,    "Capitalize word" },                /* C */
  415. { WWordFD,    "delete the following word" },            /* D */
  416. { WSentF,    "move forward sentence" },            /* E */
  417. { WWordF,    "move forward word" },                /* F */
  418. { MNotImpl,    "@" },                        /* G */
  419. { WParaMark,    "mark the current paragraph" },            /* H */
  420. { MNotImpl,    "@" },                        /* I */
  421. { MNotImpl,    "@" },                        /* J */
  422. { WSentFD,    "delete the following sentence" },        /* K */
  423. { WWordLow,    "lowercase word" },                /* L */
  424. { MNotImpl,    "@" },                        /* M */
  425. { MNotImpl,    "@" },                        /* N */
  426. { MNotImpl,    "@" },                        /* O */
  427.  
  428. { MNotImpl,    "@" },                        /* P */
  429. { WParaFill,    "fill pargraph (^U-justify, ^U^U-unjustify" },    /* Q */
  430. { MReplace,    "global search and replace string" },        /* R */
  431. { WLineCenter,    "center line" },                /* S */
  432. { WWordTran,    "interchange words" },                /* T */
  433. { WWordUp,    "UPPERCASE word" },                /* U */
  434. { CScrnB,    "move to the previous screen" },        /* V */
  435. { RRegCopy,    "copy region to kill buffer" },            /* W */
  436. { MNotImpl,    "@" },                        /* X */
  437. { MNotImpl,    "@" },                        /* Y */
  438. { MNotImpl,    "@" },                        /* Z */
  439. { WParaB,    "move backward paragraph" },            /* [ */
  440. { WJoinGray,    "delete surrounding whitespace and insert space" },    /* \ */
  441. { WParaF,    "move forward paragraph" },            /* ] */
  442. { MNotImpl,    "@" },                        /* ^ */
  443. { MNotImpl,    "@" },                        /* _ */
  444.  
  445. { MNotImpl,    "@" },                        /* ` */
  446. { WSentB,    "move backward sentence" },            /* a */
  447. { WWordB,    "move backward word" },                /* b */
  448. { WWordCap,    "Capitalize word" },                /* c */
  449. { WWordFD,    "delete the following word" },            /* d */
  450. { WSentF,    "move forward sentence" },            /* e */
  451. { WWordF,    "move forward word" },                /* f */
  452. { MNotImpl,    "@" },                        /* g */
  453. { WParaMark,    "mark the current paragraph" },            /* h */
  454. { MNotImpl,    "@" },                        /* i */
  455. { MNotImpl,    "@" },                        /* j */
  456. { WSentFD,    "delete the following sentence" },        /* k */
  457. { WWordLow,    "lowercase word" },                /* l */
  458. { MNotImpl,    "@" },                        /* m */
  459. { MNotImpl,    "@" },                        /* n */
  460. { MNotImpl,    "@" },                        /* o */
  461.  
  462. { MNotImpl,    "@" },                        /* p */
  463. { WParaFill,    "fill pargraph (^U-justify, ^U^U-unjustify" },    /* q */
  464. { MReplace,    "global search and replace string" },        /* r */
  465. { WLineCenter,    "center line" },                /* s */
  466. { WWordTran,    "interchange words" },                /* t */
  467. { WWordUp,    "UPPERCASE word" },                /* u */
  468. { CScrnB,    "move to the previous screen" },        /* v */
  469. { RRegCopy,    "copy region to kill buffer" },            /* w */
  470. { MNotImpl,    "@" },                        /* x */
  471. { MNotImpl,    "@" },                        /* y */
  472. { MNotImpl,    "@" },                        /* z */
  473. { MNotImpl,    "@" },                        /* { */
  474. { MNotImpl,    "@" },                        /* | */
  475. { MNotImpl,    "@" },                        /* } */
  476. { BBufUnmod,    "clear the buffer modified flag" },        /* ~ */
  477. { WWordBD,    "delete the preceding word" } };        /* ^? */
  478.  
  479.     /* function keys */
  480.  
  481. #define NUMFUNCKEYS    (sizeof(func) / sizeof(func[0]))
  482. #if defined(MSDOS)
  483. static struct func_cmd func[] = {            /* 0 */
  484. { MNotImpl,    "@",                        "" },
  485. { MNotImpl,    "@",                        "" },
  486. { MNotImpl,    "@",                        "" },
  487. { RMarkSet,    "set the mark to the point",            "Ctrl-2" },
  488. { MNotImpl,    "@",                        "" },
  489. { MNotImpl,    "@",                        "" },
  490. { MNotImpl,    "@",                        "" },
  491. { MNotImpl,    "@",                        "" },
  492. { MNotImpl,    "@",                        "" },
  493. { MNotImpl,    "@",                        "" },
  494.                             /* 10 */
  495. { MNotImpl,    "@",                        "" },
  496. { MNotImpl,    "@",                        "" },
  497. { MNotImpl,    "@",                        "" },
  498. { MNotImpl,    "@",                        "" },
  499. { MNotImpl,    "@",                        "" },
  500. { MNotImpl,    "@",                        "Shift-Tab" },
  501. { WParaFill,    "fill pargraph (^U-justify, ^U^U-unjustify",    "Alt-Q" },
  502. { RRegCopy,    "copy region to kill buffer",            "Alt-W" },
  503. { WSentF,    "move forward sentence",            "Alt-E" },
  504. { MReplace,    "global search and replace string",        "Alt-R" },
  505.                             /* 20 */
  506. { WWordTran,    "interchange words",                "Alt-T" },
  507. { MNotImpl,    "@",                        "Alt-Y" },
  508. { WWordUp,    "UPPERCASE word",                "Alt-U" },
  509. { MNotImpl,    "@",                        "Alt-I" },
  510. { MNotImpl,    "@",                        "Alt-O" },
  511. { MNotImpl,    "@",                        "Alt-P" },
  512. { MNotImpl,    "@",                        "" },
  513. { MNotImpl,    "@",                        "" },
  514. { MNotImpl,    "@",                        "" },
  515. { MNotImpl,    "@",                        "" },
  516.                             /* 30 */
  517. { WSentB,    "move backward sentence",            "Alt-A" },
  518. { WLineCenter,    "center line",                    "Alt-S" },
  519. { WWordFD,    "delete the following word",            "Alt-D" },
  520. { WWordF,    "move forward word",                "Alt-F" },
  521. { MNotImpl,    "@",                        "Alt-G" },
  522. { WParaMark,    "mark the current paragraph",            "Alt-H" },
  523. { MNotImpl,    "@",                        "Alt-J" },
  524. { WSentFD,    "delete the following sentence",        "Alt-K" },
  525. { WWordLow,    "lowercase word",                "Alt-L" },
  526. { MNotImpl,    "@",                        "" },
  527.                             /* 40 */
  528. { MNotImpl,    "@",                        "" },
  529. { MNotImpl,    "@",                        "" },
  530. { MNotImpl,    "@",                        "" },
  531. { MNotImpl,    "@",                        "" },
  532. { MNotImpl,    "@",                        "Alt-Z" },
  533. { MNotImpl,    "@",                        "Alt-X" },
  534. { WWordCap,    "Capitalize word",                "Alt-C" },
  535. { CScrnB,    "move to the previous screen",            "Alt-V" },
  536. { WWordB,    "move backward word",                "Alt-B" },
  537. { MNotImpl,    "@",                        "Alt-N" },
  538.                             /* 50 */
  539. { MNotImpl,    "@",                        "Alt-M" },
  540. { MNotImpl,    "@",                        "" },
  541. { MNotImpl,    "@",                        "" },
  542. { MNotImpl,    "@",                        "" },
  543. { MNotImpl,    "@",                        "" },
  544. { MNotImpl,    "@",                        "" },
  545. { MNotImpl,    "@",                        "" },
  546. { MNotImpl,    "@",                        "" },
  547. { MNotImpl,    "@",                        "" },
  548. { HHelp,    "help",                        "F1" },
  549.                             /* 60 */
  550. { MNotImpl,    "@",                        "F2" },
  551. { CLineAED,    "delete the current line",            "F3" },
  552. { MNotImpl,    "@",                        "F4" },
  553. { FBufNext,    "move to the next buffer in the ring",        "F5" },
  554. { DWindSwap,    "move / switch to the other window",        "F6" },
  555. { WIndThis,    "open a line and indent it the same as current","F7" },
  556. { FFileSave,    "save the buffer using current name",        "F8" },
  557. #if !defined(NOCALC)
  558. { UCalc,    "RPN calculator",                "F9" },
  559. #else
  560. { MNotImpl,    "@",                        "F9" },
  561. #endif
  562. { DCal,        "display a calendar for the current month"    "F10" },
  563. { MNotImpl,    "@",                        "" },
  564.                             /* 70 */
  565. { MNotImpl,    "@",                        "" },
  566. { FBufBeg,    "move to the beginning of the buffer",        "Home" },
  567. { CLineB,    "move to the previous line",            "Up Arrow" },
  568. { CScrnB,    "move to the previous screen",            "PgUp" },
  569. { MNotImpl,    "@",                        "" },
  570. { CCharB,    "move backward character",            "Left Arrow" },
  571. { MNotImpl,    "@",                        "" },
  572. { CCharF,    "move forward character",            "Right Arrow" },
  573. { MNotImpl,    "@",                        "" },
  574. { FBufEnd,    "move to the end of the buffer",        "End" },
  575.                             /* 80 */
  576. { CLineF,    "move to the next line",            "Down Arrow" },
  577. { CScrnF,    "move to the next screen",            "PgDn" },
  578. { WInsNLA,    "open line",                    "Ins" },
  579. { CCharFD,    "delete the following character",        "Del" },
  580. { MNotImpl,    "@",                        "Shift-F1" },
  581. { MNotImpl,    "@",                        "Shift-F2" },
  582. { MNotImpl,    "@",                        "Shift-F3" },
  583. { MNotImpl,    "@",                        "Shift-F4" },
  584. { MNotImpl,    "@",                        "Shift-F5" },
  585. { DWindTog,    "toggle between one and two windows",        "Shift-F6" },
  586.                             /* 90 */
  587. { MNotImpl,    "@",                        "Shift-F7" },
  588. { FFileFind,    "find a file, creating new buffer",        "Shift-F8" },
  589. { MNotImpl,    "@",                        "Shift-F9" },
  590. { MExit,    "exit / quit the editor",            "Shift-F10" },
  591. { MNotImpl,    "@",                        "Ctrl-F1" },
  592. { RRegCopy,    "copy region to kill buffer",            "Ctrl-F2" },
  593. { RRegDelete,    "delete region to kill buffer: cut",        "Ctrl-F3" },
  594. { RYank,    "yank kill buffer: paste",            "Ctrl-F4" },
  595. { MNotImpl,    "@",                        "Ctrl-F5" },
  596. { MNotImpl,    "@",                        "Ctrl-F6" },
  597.                             /* 100 */
  598. { MNotImpl,    "@",                        "Ctrl-F7" },
  599. { MNotImpl,    "@",                        "Ctrl-F8" },
  600. { RMarkSet,    "set the mark to the point",            "Ctrl-F9" },
  601. { MNotImpl,    "@",                        "Ctrl-F10" },
  602. { MNotImpl,    "@",                        "Alt-F1" },
  603. { MNotImpl,    "@",                        "Alt-F2" },
  604. { MNotImpl,    "@",                        "Alt-F2" },
  605. { MNotImpl,    "@",                        "Alt-F4" },
  606. { MNotImpl,    "@",                        "Alt-F5" },
  607. { MNotImpl,    "@",                        "Alt-F6" },
  608.                             /* 110 */
  609. { MNotImpl,    "@",                        "Alt-F7" },
  610. { MNotImpl,    "@",                        "Alt-F8" },
  611. { MNotImpl,    "@",                        "Alt-F9" },
  612. { MNotImpl,    "@",                        "Alt-F10" },
  613. { MNotImpl,    "@",                        "Ctrl-PrtSc" },
  614. { WWordB,    "move backward word",                "Ctrl-Left Arrow" },
  615. { WWordF,    "move forward word",                "Ctrl-Right Arrow" },
  616. { MNotImpl,    "@",                        "Ctrl-End" },
  617. { MNotImpl,    "@",                        "Ctrl-PgDn" },
  618. { MNotImpl,    "@",                        "Ctrl-Home" },
  619.                             /* 120 */
  620. { MNotImpl,    "@",                        "Alt-1" },
  621. { MNotImpl,    "@",                        "Alt-2" },
  622. { MNotImpl,    "@",                        "Alt-3" },
  623. { MNotImpl,    "@",                        "Alt-4" },
  624. { MNotImpl,    "@",                        "Alt-5" },
  625. { MNotImpl,    "@",                        "Alt-6" },
  626. { MNotImpl,    "@",                        "Alt-7" },
  627. { MNotImpl,    "@",                        "Alt-8" },
  628. { MNotImpl,    "@",                        "Alt-9" },
  629. { MNotImpl,    "@",                        "Alt-0" },
  630.                             /* 130 */
  631. { MNotImpl,    "@",                        "Alt--" },
  632. { WPrintLine,    "display line counts",                "Alt-=" },
  633. { MNotImpl,    "@",                        "Ctrl-PgUp" },
  634.     /* the following are mapped in jaguar.c */
  635. #if !defined(SYSMGR)
  636. { JMenu,    "bring up the menus",                "MENU" },
  637. { JSetup,    "invoke the set up application",        "SET UP" },
  638. { JFiler,    "invoke the Filer application",            "FILER" },
  639. { JComm,    "invoke the communications application",    "COMM" },
  640. { JAppt,    "invoke the appointment book application",    "APPT" },
  641. { JPhone,    "invoke the telephone book application",    "PHONE" },
  642. { JMemo,    "invoke the memo application",            "MEMO" },
  643.                             /* 140 */
  644. { JLotus,    "invoke Lotus 1-2-3",                "LOTUS" },
  645. { JHPCalc,    "invoke the HP calculator",            "HP CALC" } };
  646. #else
  647. { JMenu,    "bring up the menus",                "MENU" } };
  648. #endif
  649. #else
  650. static struct func_cmd func[] = {            /* 0 */
  651. { MNotImpl,    "@",                        "" } };
  652. #endif
  653.  
  654. static char descrbuf[SMALLBUFFSIZE];
  655.  
  656. /* ------------------------------------------------------------ */
  657.  
  658. /* Return the command's description. */
  659.  
  660. char *
  661. TabDescr(key, table)
  662.     int key;
  663.     int table;
  664.     {
  665.     if (key == KEYQUIT) return("Quit");
  666.     if (key == KEYABORT) return("Abort");
  667.  
  668.     if (key >= 256) table = 3;
  669.     switch (table) {
  670.  
  671.     case 0:
  672.         if (key > 127 && c.g.meta_handle == 'M')
  673.             return(TabDescr(key & 0x7f, 2));
  674.         return(TPrintChar(key & 0x7f, NULL));
  675.         /* break; */
  676.  
  677.     case 1:
  678.         key &= 0x7f;
  679.         TPrintChar(ZCX, descrbuf);
  680.         strcat(descrbuf, " ");
  681.         TPrintChar(key, descrbuf + strlen(descrbuf));
  682.         return(descrbuf);
  683.         /* break; */
  684.  
  685.     case 2:
  686.         key &= 0x7f;
  687.         TPrintChar(ESC, descrbuf);
  688.         strcat(descrbuf, " ");
  689.         TPrintChar(key, descrbuf + strlen(descrbuf));
  690.         return(descrbuf);
  691.         /* break; */
  692.  
  693.     case 3:
  694.         if (key >= 256) key &= 0xff;
  695.         if (key >= NUMFUNCKEYS)
  696.             return("???");
  697.         else    return(func[key].keyname);
  698.         /* break; */
  699.         }
  700.     }
  701.  
  702.  
  703. /* ------------------------------------------------------------ */
  704.  
  705. /* Invoke the specifed key from the specified table. */
  706.  
  707. void
  708. TabDispatch(key, table)
  709.     int key;
  710.     int table;
  711.     {
  712.     if (key == KEYQUIT) {
  713.         MExit();
  714.         return;
  715.         }
  716.     if (key == KEYABORT) {
  717.         MAbort();
  718.         return;
  719.         }
  720.  
  721.     if (key >= 256) table = 3;
  722.     switch (table) {
  723.  
  724.     case 0:
  725.         if (key > 127) {
  726.             if (c.g.meta_handle == 'M')
  727.                 (*meta[key & 0x7f].proc)();
  728.             else if (c.g.meta_handle == 'I')
  729.                 MInsChar();
  730.             else    MNotImpl();
  731.             }        
  732.         else    (*base[key & 0x7f].proc)();
  733.         break;
  734.  
  735.     case 1:
  736.         (*ctlx[key & 0x7f].proc)();
  737.         break;
  738.  
  739.     case 2:
  740.         (*meta[key & 0x7f].proc)();
  741.         break;
  742.  
  743.     case 3:
  744.         if (key >= 256) key &= 0xff;
  745.         if (key >= NUMFUNCKEYS)
  746.             MNotImpl();
  747.         else    (*func[key].proc)();
  748.         break;
  749.         }
  750.     }
  751.  
  752.  
  753. /* ------------------------------------------------------------ */
  754.  
  755. /* Return a pointer to the help string for the specified command. */
  756.  
  757. char *
  758. TabHelp(key, table)
  759.     int key;
  760.     int table;
  761.     {
  762.     if (key == KEYQUIT) return("exit / quit the editor");
  763.     if (key == KEYABORT) return("abort, cancel");
  764.     if (key >= 256) table = 3;
  765.     switch (table) {
  766.  
  767.     case 0:
  768.         if (key > 127) {
  769.             if (c.g.meta_handle == 'M')
  770.                 return(meta[key & 0x7F].help);
  771.             else if (c.g.meta_handle == 'I')
  772.                 return("^");
  773.             else    return("@");
  774.             }        
  775.         return(base[key & 0x7f].help);
  776.         /* break; */
  777.  
  778.     case 1:
  779.         return(ctlx[key & 0x7f].help);
  780.         /* break; */
  781.  
  782.     case 2:
  783.         return(meta[key & 0x7f].help);
  784.         /* break; */
  785.  
  786.     case 3:
  787.         if (key >= 256) key &= 0xff;
  788.         if (key >= NUMFUNCKEYS)
  789.             return("@");
  790.         else    return(func[key].help);
  791.         /* break; */
  792.         }
  793.     }
  794.  
  795.  
  796. /* ------------------------------------------------------------ */
  797.  
  798. /* Return the next command table or 0 if not a prefix. */
  799.  
  800. int
  801. TabTable(key, table)
  802.     int key;
  803.     int table;
  804.     {
  805.     if (key == KEYQUIT) return(0);
  806.     if (key == KEYABORT) return(0);
  807.  
  808.     if (key >= 256) return(3);
  809.     if (table == 0) {
  810.         if (key == ZCX) return(1);
  811.         else if (key == ESC) return(2);
  812.         else if (key >= 256) return(3);
  813.         }
  814.     return(0);
  815.     }
  816.  
  817.  
  818. /* ------------------------------------------------------------ */
  819.  
  820. /* Return True if the command is a deletion (kill) command or False if
  821. not. */
  822.  
  823. FLAG
  824. TabIsDelete(key, table)
  825.     int key;
  826.     int table;
  827.     {
  828.     void (*cmd)();
  829.  
  830.     if (key == KEYQUIT) return(FALSE);
  831.     if (key == KEYABORT) return(FALSE);
  832.     if (key >= 256) table = 3;
  833.     switch (table) {
  834.  
  835.     case 0:        cmd = base[key & 0x7f].proc;    break;
  836.     case 1:        cmd = ctlx[key & 0x7f].proc;    break;
  837.     case 2:        cmd = meta[key & 0x7f].proc;    break;
  838.     case 3:        if (key >= 256) key &= 0xff;
  839.             if (key >= NUMFUNCKEYS)
  840.                 cmd = MNotImpl;
  841.             else    cmd = func[key].proc;
  842.             break;
  843.         }
  844.     return(cmd == CLineFD ||
  845.         cmd == CLineAED ||
  846.         cmd == MMakeDelete ||
  847.         cmd == RRegDelete ||
  848.         cmd == RRegCopy ||
  849.         cmd == WSentFD ||
  850.         cmd == WWordBD ||
  851.         cmd == WWordFD);
  852.     }
  853.  
  854.  
  855. /* ------------------------------------------------------------ */
  856.  
  857. /* Return True if the command is a vertical motion command or False if
  858. not. */
  859.  
  860. FLAG
  861. TabIsVMove(key, table)
  862.     int key;
  863.     int table;
  864.     {
  865.     void (*cmd)();
  866.  
  867.     if (key == KEYQUIT) return(FALSE);
  868.     if (key == KEYABORT) return(FALSE);
  869.     if (key >= 256) table = 3;
  870.     switch (table) {
  871.  
  872.     case 0:        cmd = base[key & 0x7f].proc;    break;
  873.     case 1:        cmd = ctlx[key & 0x7f].proc;    break;
  874.     case 2:        cmd = meta[key & 0x7f].proc;    break;
  875.     case 3:        if (key >= 256) key &= 0xff;
  876.             if (key >= NUMFUNCKEYS)
  877.                 cmd = MNotImpl;
  878.             else    cmd = func[key].proc;
  879.             break;
  880.         }
  881.     return(cmd == CLineB || cmd == CLineF);
  882.     }
  883.  
  884.  
  885. /* ------------------------------------------------------------ */
  886.  
  887. /* Return the number of function keys. */
  888.  
  889. int
  890. TabNumFunc()
  891.     {
  892.     return(NUMFUNCKEYS);
  893.     }
  894.  
  895.  
  896. /* end of TABLE.C -- Command Table Routines */
  897.